// security
import fetch from '../config/fetch'
import { getChannelCode } from '../config/utils'
import { API_PATH } from '../config/env'

/**
 * 登录
 */
export const login = (phone, verifyCode) => fetch(API_PATH + '/security/login', {
  channel_code: getChannelCode(),
  phone: phone,
  verify_code: verifyCode
}, 'POST')

/**
 * 绑定手机号码
 */
export const bindAccount = (token, phone, verifyCode) => fetch(API_PATH + '/security/bind-account', {
  token: token,
  phone: phone,
  verify_code: verifyCode
}, 'POST')

/**
 * 检测token
 */
export const checkToken = (token) => fetch(API_PATH + '/security/check-token', {
  token: token
}, 'POST')

/**
 * 创建账号
 */
export const accountCreate = (token, phone, pwd) => fetch(API_PATH + '/security/account-create', {
  token: token,
  phone: phone,
  pwd: pwd
}, 'POST')

/**
 * 获取验证码
 */
export const verifyCode = (phone, scenario) => fetch(API_PATH + '/security/get-verify-code', {
  phone: phone,
  scenario: scenario
}, 'POST')

/**
 * 微信登录
 */
export const wechatLogin = (code) => fetch(API_PATH + '/security/wechat-login', {
  channel_code: getChannelCode(),
  code: code
}, 'POST')

/**
 * 微博登录
 */
export const weiboLogin = (code) => fetch(API_PATH + '/security/weibo-login', {
  channel_code: getChannelCode(),
  code: code
}, 'POST')

/**
 * qq登录
 */
export const qqLogin = (code) => fetch(API_PATH + '/security/qq-login', {
  channel_code: getChannelCode(),
  code: code
}, 'POST')
